# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.

#TODO: Clean everything up!

class ApplicationController < ActionController::Base
  include AuthenticatedSystem
  
  before_filter :login_required
  
  def check_cookies
    session_key = ActionController::Base.session.first[:session_key]
    session_cookie = cookies[session_key]
    
    if session_cookie.nil? && params[:confirmed]
      redirect_to :controller => 'users', :action => 'login', :message => 'Je hebt geen cookies aanstaan!'
      return false
    elsif 
      session_cookie.nil? && params[:confirmed].nil?
        redirect_to request.env['REQUEST_URI'] + '?confirmed=true'
        return false
    end
    return true
  end
end